﻿<Application 
    x:Class="Spotted.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:app="clr-namespace:Spotted.Core"
    xmlns:map="clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps"
    xmlns:tk="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit">

    <!--Application Resources-->
    <Application.Resources>
        <app:SpottedBootstrapper x:Name="bootstrapper" />

        <!-- Define the main colors for the Spotted color scheme -->
        <SolidColorBrush x:Key="SpottedMainColorBrush" Color="#3C4DD9" />
        <SolidColorBrush x:Key="SpottedLightMainColorBrush" Color="#3C78D9" />
        <SolidColorBrush x:Key="SpottedSecondaryColorBrush" Color="Black" />
        <SolidColorBrush x:Key="SpottedBackgroundColorBrush" Color="White" />
        <SolidColorBrush x:Key="SpottedGrayColorBrush" Color="#9D9D9D" />
        <SolidColorBrush x:Key="SpottedLightGrayBackgroundBrush" Color="#D6D2D2" />

        <Style x:Key="SmallText" BasedOn="{StaticResource PhoneTextSmallStyle}" TargetType="TextBlock">
            <Setter Property="Foreground" Value="{StaticResource SpottedGrayColorBrush}" />
            <Setter Property="Margin" Value="0" />
        </Style>

        <Style TargetType="UserControl">
            <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyNormal}" />
            <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeNormal}" />
        </Style>

        <Style TargetType="app:SpottedPageBase">
            <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyNormal}" />
            <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeNormal}" />
        </Style>

        <Style TargetType="Grid">
            <Setter Property="Background" Value="{StaticResource SpottedBackgroundColorBrush}" />
        </Style>
        
        <Style x:Key="SpottedTitle" TargetType="TextBlock">
            <Setter Property="Foreground" Value="{StaticResource SpottedMainColorBrush}" />
            <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeLarge}" />
            <Setter Property="FontWeight" Value="ExtraBold" />
        </Style>

        <!-- Base style for Pushpins -->
        <Style TargetType="map:Pushpin" x:Key="BasePushPin">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="map:Pushpin">
                        <Grid>
                            <Ellipse Fill="{TemplateBinding Background}"
                                     Stroke="Black" StrokeThickness="3"
                                     Height="20" Width="20" />
                            <ContentPresenter HorizontalAlignment="Center"
                                  Content="{TemplateBinding Content}"
                                  ContentTemplate="{TemplateBinding ContentTemplate}"
                                  Margin="4" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <!-- Center Location Pushpin -->
        <Style TargetType="map:Pushpin" BasedOn="{StaticResource BasePushPin}" x:Key="centerPushpin">
            <Setter Property="Background" Value="{StaticResource PhoneAccentColor}" />
        </Style>

        <!-- General Location Pushpin -->
        <Style TargetType="map:Pushpin" BasedOn="{StaticResource BasePushPin}" x:Key="locationPushpin">
            <Setter Property="Background" Value="{StaticResource SpottedMainColorBrush}" />
        </Style>

        <Style x:Key="PlacesListboxText" TargetType="TextBlock">
            <Setter Property="Foreground" Value="{StaticResource SpottedSecondaryColorBrush}" />
            <Setter Property="FontFamily" Value="Segoe WP" />
            <Setter Property="FontSize" Value="26.667" />
        </Style>

        <!-- Inline button Template style -->
        <ControlTemplate TargetType="Button" x:Key="InlineButton">
            <Grid Background="Transparent">
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup x:Name="CommonStates">
                        <VisualState x:Name="Normal">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentContainer">
                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SpottedBackgroundColorBrush}"/>
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="ButtonBackground">
                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SpottedMainColorBrush}"/>
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="ButtonBackground">
                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SpottedLightMainColorBrush}" />
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="Pressed">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentContainer">
                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SpottedMainColorBrush}"/>
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="ButtonBackground">
                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SpottedMainColorBrush}"/>
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="ButtonBackground">
                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SpottedBackgroundColorBrush}" />
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>
                <Border x:Name="ButtonBackground" CornerRadius="5" Padding="5,3" BorderThickness="2">
                    <ContentControl x:Name="ContentContainer" ContentTemplate="{TemplateBinding ContentTemplate}"
                                    Content="{TemplateBinding Content}" FontSize="{TemplateBinding FontSize}"
                                    HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                    Padding="{TemplateBinding Padding}"
                                    VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
                </Border>
            </Grid>
        </ControlTemplate>

        <!-- Textbox Control Template -->
        <Style x:Key="SpottedEntryFieldBase" TargetType="Control">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Control">
                        <Grid Background="Transparent">
                            <Border x:Name="EnabledBorder" BorderBrush="{StaticResource SpottedSecondaryColorBrush}"
                                BorderThickness="1" CornerRadius="12" Padding="0" Background="{StaticResource SpottedLightGrayBackgroundBrush}">
                                <ContentControl x:Name="ContentElement" BorderThickness="0" HorizontalContentAlignment="Stretch"
                                        Padding="2" VerticalContentAlignment="Stretch" Margin="12,5"
                                        FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" />
                            </Border>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        
        <Style x:Key="SpottedTextBox" BasedOn="{StaticResource SpottedEntryFieldBase}" TargetType="TextBox" />
        <Style x:Key="SpottedPasswordBox" BasedOn="{StaticResource SpottedEntryFieldBase}" TargetType="PasswordBox" />
        
        <!-- ListPicker -->
        <Style TargetType="tk:ListPicker">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="tk:ListPicker">
                        <StackPanel>
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="PickerStates">
                                    <VisualState x:Name="Normal"/>
                                    <VisualState x:Name="Highlighted">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Border" Duration="0"
                                                                           Storyboard.TargetProperty="Background">
                                                <DiscreteObjectKeyFrame Value="{StaticResource SpottedBackgroundColorBrush}" KeyTime="0"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Border" Duration="0"
                                                                           Storyboard.TargetProperty="BorderBrush">
                                                <DiscreteObjectKeyFrame Value="{StaticResource SpottedSecondaryColorBrush}" KeyTime="0"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Grid Background="Transparent">
                                <Border x:Name="Border"
                                    BorderBrush="{StaticResource SpottedSecondaryColorBrush}"
                                    BorderThickness="1" CornerRadius="12" Padding="0"
                                    Background="{StaticResource SpottedLightGrayBackgroundBrush}">
                                    <UserControl x:Name="UserControl" Foreground="{StaticResource SpottedSecondaryColorBrush}">
                                        <StackPanel>
                                            <TextBlock x:Name="MultipleSelectionModeSummary" Margin="8 8 0 8" />
                                            <Canvas x:Name="ItemsPresenterHost" MinHeight="46">
                                                <ItemsPresenter x:Name="ItemsPresenter">
                                                    <ItemsPresenter.RenderTransform>
                                                        <TranslateTransform x:Name="ItemsPresenterTranslateTransform"/>
                                                    </ItemsPresenter.RenderTransform>
                                                </ItemsPresenter>
                                            </Canvas>
                                        </StackPanel>
                                    </UserControl>
                                </Border>
                            </Grid>
                        </StackPanel>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        
        <!-- List Picker Item -->
        <Style TargetType="tk:ListPickerItem">
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            <Setter Property="Padding" Value="8 10"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="tk:ListPickerItem">
                        <Grid Background="{TemplateBinding Background}">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="SelectionStates">
                                    <VisualState x:Name="Unselected"/>
                                    <VisualState x:Name="Selected">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentContainer"
                                                                           Storyboard.TargetProperty="Foreground" Duration="0">
                                                <DiscreteObjectKeyFrame Value="{StaticResource SpottedMainColorBrush}" KeyTime="0" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentContainer"
                                                                           Storyboard.TargetProperty="FontWeight" Duration="0">
                                                <DiscreteObjectKeyFrame Value="Bold" KeyTime="0" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <ContentControl x:Name="ContentContainer"
                                            Content="{TemplateBinding Content}"
                                            ContentTemplate="{TemplateBinding ContentTemplate}"
                                            VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                            HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                            Margin="{TemplateBinding Padding}" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Application.Resources>

</Application>